@echo off
setlocal enabledelayedexpansion

:: 设置基础路径，假设以2024开头的文件夹都在此路径下
set "basePath=D:\Unity Project\Work\launcherscene_work_built\Bundles\StandaloneWindows64\DefaultPackage"

:: 查找以2024开头的第一个文件夹，并将其路径设置为sourceFolder
for /d %%d in ("%basePath%\2024*") do (
    set "sourceFolder=%%d"
    goto :copyFiles
)

:copyFiles
if not defined sourceFolder (
    echo No folder starting with 2024 found.
    exit /b
)

set "targetFolder=D:\Unity_File\CDN\PC\DefaultPackage"

:: 删除目标文件夹中的所有内容
echo Deleting all contents in the target folder...
del /q "%targetFolder%\*"

:: 检查是否有子目录需要删除
for /d %%p in ("%targetFolder%\*") do (
    rd /s /q "%%p"
)

:: 将源文件夹中的所有内容复制到目标文件夹
echo Copying all contents from the source folder to the target folder...
xcopy "%sourceFolder%\*" "%targetFolder%\" /s /i /y

echo Operation completed.
pause
endlocal